<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2019/12/9 0009
  Time: 14:45
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" import="cn.school.service.*,cn.school.entity.*" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>Title</title>
    <script src="js/jquery-3.4.1.min.js"></script>
</head>
<body>
<%
    Long sno=Long.parseLong(request.getParameter("stuno"));
    //读取学生信息
    ////展现在form中
    //radio 性别，年级的处理，日期的处理
    //修改完成，再提交保存
    StudentService studentService=new StudentService();
    Student student=studentService.get(sno);
    if(student==null){
        out.print("<script>alert('对象不存在');history.back();</script>");
        return;
    }
%>
<form action="doUpdateStudent.jsp" method="post">
    <input type="hidden" name="stuno" value="<%=student.getStuno()%>"/>
    <p>
        姓名:<input type="text" name="sname" value="<%=student.getSname()%>"/>
    </p>
    <p>
        性别：<input type="radio" name="gender" value="男"/>男
        <input type="radio" name="gender" value="女"/>女
        <input type="radio" name="gender" value="妖"/>妖
    </p>
    <p>
        <%
            GradeService gs=new GradeService();
            //SimpleDateFormat
        %>
        年级：
        <select name="gradeid" id="gradeid">
            <%
                for(Grade g:gs.findALL()){
            %>
            <option value="<%=g.getId()%>" <%if(g.getId()==student.getGradeid())out.print("selected");%>><%=g.getGname()%></option>
            <%}%>
         </select>
    </p>
    <p>
        入学时间:<input type="text" name="enterdate" value="<%=student.getEnterdate()%>"/>
    </p>
    <p>
        <input type="submit" value="保存"/>
    </p>
</form>
</body>
<script>
    $(function(){
        //$("#gradeid").val('<%=student.getGradeid()%>');
        $("input[name=gender][value='<%=student.getSex()%>']").prop("checked",true);
    });
</script>
</html>
